﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiNoiseGenerator : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiNoiseGenerator(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiNoiseGenerator_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiNoiseGenerator obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiNoiseGenerator()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiNoiseGenerator(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGiNoiseGenerator cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiNoiseGenerator_cast(OdRxObject.getCPtr(pObj));
			OdGiNoiseGenerator result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiNoiseGenerator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiNoiseGenerator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiNoiseGenerator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiNoiseGenerator_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiNoiseGenerator_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiNoiseGenerator_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiNoiseGenerator createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiNoiseGenerator_createObject__SWIG_0();
			OdGiNoiseGenerator result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiNoiseGenerator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiNoiseGenerator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiNoiseGenerator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void initSeed(uint seed)
		{
			GlobalsPINVOKE.OdGiNoiseGenerator_initSeed(this.swigCPtr, seed);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual double noise1d(double point)
		{
			double result = GlobalsPINVOKE.OdGiNoiseGenerator_noise1d(this.swigCPtr, point);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double noise2d(OdGePoint2d point)
		{
			double result = GlobalsPINVOKE.OdGiNoiseGenerator_noise2d(this.swigCPtr, OdGePoint2d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double noise3d(OdGePoint3d point)
		{
			double result = GlobalsPINVOKE.OdGiNoiseGenerator_noise3d(this.swigCPtr, OdGePoint3d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double noise(double[] point, int len)
		{
			double result = GlobalsPINVOKE.OdGiNoiseGenerator_noise(this.swigCPtr, Helpers.MarshaldoubleFixedArray(point), len);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double turbulence(OdGePoint3d point, double freq)
		{
			double result = GlobalsPINVOKE.OdGiNoiseGenerator_turbulence(this.swigCPtr, OdGePoint3d.getCPtr(point), freq);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double oNoise(OdGePoint3d point, double freq)
		{
			double result = GlobalsPINVOKE.OdGiNoiseGenerator_oNoise(this.swigCPtr, OdGePoint3d.getCPtr(point), freq);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double fBm(OdGePoint3d point, double H, double lacunarity, double octaves)
		{
			double result = GlobalsPINVOKE.OdGiNoiseGenerator_fBm(this.swigCPtr, OdGePoint3d.getCPtr(point), H, lacunarity, octaves);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiNoiseGenerator createObject(uint seed)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiNoiseGenerator_createObject__SWIG_1(seed);
			OdGiNoiseGenerator result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiNoiseGenerator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiNoiseGenerator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiNoiseGenerator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
